package com.nf.service;

import com.nf.mapper.TestDao;
import org.springframework.beans.factory.annotation.Autowired;

public class TestServiceImpl implements TestService{
    //控制权交给了ioc容器Beanfactory（web application，启动tomcat就启动）
    //如果添加注解，就可以不添加set了
    //@Autowired
    private TestDao testDao;

    public TestDao getTestDao() {
        return testDao;
    }

    public void setTestDao(TestDao testDao) {
        System.out.println("11");
        this.testDao = testDao;
    }

    private Float rate;

    public Float getRate() {
        return rate;
    }

    public void setRate(Float rate) {
        System.out.println("2、为bean属性设置值vlue或引入其他bean");
        this.rate = rate;
    }

    public TestServiceImpl() {
        System.out.println("1、通过构造器或工厂方法创建bean实例"+this);
    }

    @Override
    public String getString() {
        return testDao.getFloat()/rate+"美元";
    }
}
